package org.sky.service.serviceImpl;

import org.sky.base.DaoSupport;
import org.sky.model.Person;
import org.sky.service.PersonService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.*;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.Query;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-10-21
 * Time: 下午8:29
 * To change this template use File | Settings | File Templates.
 */

@Service
@Transactional
public class PersonServiceImpl extends DaoSupport<Person> implements PersonService {

    public Person findPersonByUserName(String userName) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("userName", userName);
        return this.findSpecialObject(Person.class, params);
    }

    public List findPersonByUserId(int id) {
        Query query = em.createQuery("from Person p where p.id = ?1");
        query.setParameter(1,id);
        System.out.println(query.toString());
        return query.getResultList();
    }
}
